﻿
namespace BigPixels
{
    using System;
    using System.Windows.Forms;
    using System.Reflection;
    using System.IO;
	using System.Configuration;

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        public static ApplicationSettings Load()
        {
			var settings = new ApplicationSettings();

			try
			{
				var fileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BigPixels.config");
				settings = XmlSerializer<ApplicationSettings>.Load(fileName);
			}
			catch (FileNotFoundException)
			{
				Save(settings);
			}

            return settings;
        }


        public static void Save(ApplicationSettings settings)
        {
			var fileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BigPixels.config");
			XmlSerializer<ApplicationSettings>.Save(fileName, settings);
        }
    }
}
